﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Data.SqlClient;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using DevExpress.Skins;
using DevExpress.LookAndFeel;
using DevExpress.UserSkins;
using DevExpress.XtraEditors;


namespace gpao2012
{
    public partial class principale : XtraForm
    {
        public SqlConnection con;


        public principale()
        {
            InitializeComponent();
            InitGrid();

            //intiation connection base
            con = new SqlConnection(@"Data Source=.\SQLEXPRESS;Initial Catalog=gpaogscofficiel;Integrated Security=True");

            //textstatus.ItemAppearance.SetFont(Color="green");
            con.Open();
            textstatus.Caption = "connection établie !";
            con.Close();
        }
        BindingList<Person> gridDataList = new BindingList<Person>();
        void InitGrid()
        {
            gridDataList.Add(new Person("John", "Smith"));
            gridDataList.Add(new Person("Gabriel", "Smith"));
            gridDataList.Add(new Person("Ashley", "Smith", "some comment"));
            gridDataList.Add(new Person("Adrian", "Smith", "some comment"));
            gridDataList.Add(new Person("Gabriella", "Smith", "some comment"));

        }



        private void barButtonItem4_ItemClick_1(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {

            contenaire_principale.Panel2.Controls.Clear();
            UserControl infosoc = new infosoc();
            contenaire_principale.Panel2.Controls.Add(infosoc);
            infosoc.Dock = System.Windows.Forms.DockStyle.Fill;

        }

        private void barButtonItem16_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            Application.Exit();

        }

        private void barButtonItem17_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            contenaire_principale.Panel2.Controls.Clear();
            UserControl phaseproduction = new Phase_de_production();
            contenaire_principale.Panel2.Controls.Add(phaseproduction);
            phaseproduction.Dock = System.Windows.Forms.DockStyle.Fill;


        }

        private void barButtonItem18_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            contenaire_principale.Panel2.Controls.Clear();
            UserControl listedesopertaion = new listedesoperations();
            contenaire_principale.Panel2.Controls.Add(listedesopertaion);
            listedesopertaion.Dock = System.Windows.Forms.DockStyle.Fill;

        }

        private void barButtonItem19_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            contenaire_principale.Panel2.Controls.Clear();
            UserControl listedesmachines = new listedesmachines();
            contenaire_principale.Panel2.Controls.Add(listedesmachines);
            listedesmachines.Dock = System.Windows.Forms.DockStyle.Fill;

        }

        private void barButtonItem20_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            contenaire_principale.Panel2.Controls.Clear();
            UserControl listeouvrieres = new listeouvrieres();
            contenaire_principale.Panel2.Controls.Add(listeouvrieres);
            listeouvrieres.Dock = System.Windows.Forms.DockStyle.Fill;
        }

        private void barButtonItem22_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            contenaire_principale.Panel2.Controls.Clear();
            UserControl listedesarticles = new listedesarticles();
            contenaire_principale.Panel2.Controls.Add(listedesarticles);
            listedesarticles.Dock = System.Windows.Forms.DockStyle.Fill;
        }

        private void barButtonItem24_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            //var client= new listeclient
        }

        private void barButtonItem26_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            //var interr= new listeinterruptions
        }

        private void barButtonItem27_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            contenaire_principale.Panel2.Controls.Clear();
            UserControl listedesdefauts = new listedesdefauts();
            contenaire_principale.Panel2.Controls.Add(listedesdefauts);
            listedesdefauts.Dock = System.Windows.Forms.DockStyle.Fill;
        }

        private void barButtonItem70_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            contenaire_principale.Panel2.Controls.Clear();
            UserControl listecataloguetemps = new listecataloguetemp();
            contenaire_principale.Panel2.Controls.Add(listecataloguetemps);
            listecataloguetemps.Dock = System.Windows.Forms.DockStyle.Fill;
        }

        private void barButtonItem30_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            contenaire_principale.Panel2.Controls.Clear();
            UserControl listedesgammesopératoire = new listedesgammesopératoire();
            contenaire_principale.Panel2.Controls.Add(listedesgammesopératoire);
            listedesgammesopératoire.Dock = System.Windows.Forms.DockStyle.Fill;
        }

        private void barButtonItem32_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            contenaire_principale.Panel2.Controls.Clear();
            UserControl generationdepaquet = new generationdepaquet();
            contenaire_principale.Panel2.Controls.Add(generationdepaquet);
            generationdepaquet.Dock = System.Windows.Forms.DockStyle.Fill;
        }

        private void barButtonItem35_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            contenaire_principale.Panel2.Controls.Clear();
            UserControl fichedecontrole = new fichedecontrole();
            contenaire_principale.Panel2.Controls.Add(fichedecontrole);
            fichedecontrole.Dock = System.Windows.Forms.DockStyle.Fill;
        }

        private void barButtonItem48_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            contenaire_principale.Panel2.Controls.Clear();
            UserControl fichedesreparation = new fichedesreparation();
            contenaire_principale.Panel2.Controls.Add(fichedesreparation);
            fichedesreparation.Dock = System.Windows.Forms.DockStyle.Fill;
        }

        private void barButtonItem49_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            contenaire_principale.Panel2.Controls.Clear();
            UserControl mouvementdeschaines = new mouvementdeschaines();
            contenaire_principale.Panel2.Controls.Add(mouvementdeschaines);
            mouvementdeschaines.Dock = System.Windows.Forms.DockStyle.Fill;
        }

        private void barButtonItem50_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            //var affectouvmach = new AffectaionDesouvrieresposte();
            //affectouvmach.Show();
        }

        private void barButtonItem52_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            contenaire_principale.Panel2.Controls.Clear();
            UserControl planificationdeschaines = new planificationdeschaines();
            contenaire_principale.Panel2.Controls.Add(planificationdeschaines);
            planificationdeschaines.Dock = System.Windows.Forms.DockStyle.Fill;
        }

        private void barButtonItem53_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {

            contenaire_principale.Panel2.Controls.Clear();
            UserControl quifaitquoi = new quifaitquoi();
            contenaire_principale.Panel2.Controls.Add(quifaitquoi);
            quifaitquoi.Dock = System.Windows.Forms.DockStyle.Fill;
        }

        private void Listetaille_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            var grilltaille = new listedesgrillesdetailles();
            grilltaille.Show();
            contenaire_principale.Panel2.Controls.Clear();
            UserControl listedesgrillesdetailles = new listedesgrillesdetailles();
            contenaire_principale.Panel2.Controls.Add(listedesgrillesdetailles);
            listedesgrillesdetailles.Dock = System.Windows.Forms.DockStyle.Fill;
        }

        private void ribbonControl1_Click(object sender, EventArgs e)
        {

        }

        private void principale_Load(object sender, EventArgs e)
        {
          
            SqlConnection con;
            SqlCommand cmd;
            con = new SqlConnection(@"Data Source=.\SQLEXPRESS;Initial Catalog=gpaogscofficiel;Integrated Security=True");

            string sqlquery = "SELECT * FROM [gpaogscofficiel].[dbo].[info_soc]";
            con.Open();
            cmd = new SqlCommand(sqlquery, con);
          
           
            SqlDataReader mySqDataReader = cmd.ExecuteReader();
            if (mySqDataReader.Read())
            {
                string iis = mySqDataReader.GetString(1);
                if (iis != "")
                {
                    this.barButtonItem4.Enabled = false;
                }
                else
                {
                  
                   this.barButtonItem8.Enabled = false;
                   
                }
            }
            else
            {
                this.barButtonItem8.Enabled = false;
             
                 


            }
        }

        private void barButtonItem3_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {

        }

        private void barButtonItem6_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            contenaire_principale.Panel2.Controls.Clear();
            UserControl export = new export();
            contenaire_principale.Panel2.Controls.Add(export);
            export.Dock = System.Windows.Forms.DockStyle.Fill;

        }

        private void barButtonItem8_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {

            contenaire_principale.Panel2.Controls.Clear();
            UserControl infosoc = new infosoc();
            contenaire_principale.Panel2.Controls.Add(infosoc);
            infosoc.Dock = System.Windows.Forms.DockStyle.Fill;
        }

        private void barButtonItem8_ItemClick_1(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            contenaire_principale.Panel2.Controls.Clear();
            UserControl infosoc = new infosoc();
            contenaire_principale.Panel2.Controls.Add(infosoc);
            infosoc.Dock = System.Windows.Forms.DockStyle.Fill;
        }

        private void principale_Load_1(object sender, EventArgs e)
        {


            SqlConnection con;
            SqlCommand cmd;
            con = new SqlConnection(@"Data Source=.\SQLEXPRESS;Initial Catalog=gpaogscofficiel;Integrated Security=True");

            string sqlquery = "SELECT * FROM [gpaogscofficiel].[dbo].[info_soc]";
            con.Open();
            cmd = new SqlCommand(sqlquery, con);


            SqlDataReader mySqDataReader = cmd.ExecuteReader();
            if (mySqDataReader.Read())
            {
                string iis = mySqDataReader.GetString(1);
                if (iis != "")
                {
                    this.barButtonItem4.Enabled = false;
                }
                else
                {

                    this.barButtonItem8.Enabled = false;

                }
            }
            else
            {
                this.barButtonItem8.Enabled = false;




            }

        }

        private void barButtonItem6_ItemClick_1(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            
            contenaire_principale.Panel2.Controls.Clear();
            export ex = new export();
            contenaire_principale.Panel2.Controls.Add(ex);
            ex.Dock = System.Windows.Forms.DockStyle.Fill;
        }

        private void barButtonItem3_ItemClick_1(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
        
            contenaire_principale.Panel2.Controls.Clear();
           import imp = new import();
            contenaire_principale.Panel2.Controls.Add(imp);
            imp.Dock = System.Windows.Forms.DockStyle.Fill;
        }

    }
}